package com.erp.module.zhiLiang

import android.content.Context
import com.erp.Interface.OnUserDataInterface
import com.erp.contacts.Contacts
import com.erp.util.Httputil
import com.erp.util.Httputil.Call
import com.erp.util.Httputil.getparams
import org.xutils.http.RequestParams
import org.xutils.x

/**
 * Created by Administrator on 2019/3/20/020.
 * 作者：刘洋
 */
class ZhiLiangModel {
    /**获取物料类别代码 */
    fun getWuLiao_LeiBie_DaiMa(context: Context, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.WULIAO_DAIMA)
        getparams(context, params)
        x.http().get<String>(params, Call(context, onUserDataInterface))
    }

    /**获取板材质量列表 */
    fun getBanCaiZhiLiang(context: Context, page: Int, pagesize: Int,sousuoBean :IZhiLiangP.ZhiLiangSouSuoBean, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.ZHILIANG)
        getparams(context, params)
        Httputil.setProsess(params)
        params.addBodyParameter("page", page.toString())
        params.addBodyParameter("pagesize", pagesize.toString())
        params.addBodyParameter("searchParams[mq_mcode_mhs]", sousuoBean.sousuo)
        params.addBodyParameter("searchParams[is_problem]", sousuoBean.wenti)
        params.addBodyParameter("searchParams[mb_area_num]", sousuoBean.quhao)
        params.addBodyParameter("searchParams[mc_id][]",sousuoBean.wuliao)
        if ("" != sousuoBean.time_category) {
            params.addBodyParameter("searchParams[time_filter][time_category]", "mq.occurrence_time")
            params.addBodyParameter("searchParams[time_filter][start_time]",sousuoBean.startTime)
            params.addBodyParameter("searchParams[time_filter][end_time]", sousuoBean.endTime)
        }
        x.http().get(params, Call(context, onUserDataInterface))
    }
    /**确认收货 */
    fun querenShouhuo(context: Context, mq_id : String, onUserDataInterface: OnUserDataInterface) {
        var params = RequestParams(Contacts.XIUGAI_ZHILIANG + "/material_quality_consignee")
        Httputil.getparams(context, params)
        Httputil.addtoken(params!!)
        params!!.addHeader("ACCEPT", "application/json")
        params.addBodyParameter("mq_id", mq_id, Contacts.BOUNDARY)
        params.addBodyParameter("", "", Contacts.BOUNDARY)
        x.http().post<String>(params, Httputil.Call(context, onUserDataInterface))
    }
}